package com.qiyu.tech.tcc.starter.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.qiyu.datasource.annotation.UsingDataSource;
import com.qiyu.tech.tcc.starter.model.Goods;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import static com.qiyu.datasource.enums.DatasourceConfigEnum.TEST_GOODS_DB;

/**
 * @author linhao
 * @date created in 8:17 下午 2020/11/3
 */
@Mapper
@UsingDataSource(type = TEST_GOODS_DB)
public interface GoodsDao extends BaseMapper<Goods> {

    @Update("update t_goods set stock=stock-1 where id=1")
    int updateStock();

    @Update("update t_goods set stock=stock-#{num} where id=#{goodsId}")
    int updateStockFromFreeze(@Param("num")Integer num,@Param("goodsId")Integer goodsId);
}
